package com.quectel.emp.controller.scheduling;


import com.quectel.core.module.dept.dto.DeptPersonDto;
import com.quectel.core.module.scheduling.dto.SchedulingAttendanceGroupDto;
import com.quectel.core.module.scheduling.service.*;
import com.quectel.core.module.scheduling.service.mongo.MongoOriginalCheckRecordService;
import com.quectel.core.module.schedulingapply.service.*;
import com.quectel.emp.controller.BaseController;
import com.quectel.emp.util.SessionHolder;
import com.quectel.util.common.Response;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Objects;

/**
 *
 * @author ryan
 * @email ryan.ran@quectel.com
 * @date 2023/07/13 18:58
 */
@RestController
@RequestMapping("schedulingAttendanceGroup")
@Tag(name = "SchedulingAttendanceGroupController", description = "考勤组相关 API")
public class SchedulingAttendanceGroupController extends BaseController {

    private SchedulingAttendanceDailyService schedulingAttendanceDailyService;
    @DubboReference
    private SchedulingAttendanceGroupPersonBindingService schedulingAttendanceGroupPersonBindingService;
    @DubboReference
    private SchedulingAttendanceGroupHeadBindingService schedulingAttendanceGroupHeadBindingService;
    @DubboReference
    private SchedulingAttendanceDailyTimeService schedulingAttendanceDailyTimeService;
    @DubboReference
    private SchedulingAttendanceGroupPersonWorkTimeConfigService schedulingAttendanceGroupPersonWorkTimeConfigService;
    @DubboReference
    private SchedulingApplyRecordService schedulingApplyRecordService;
    @DubboReference
    private SchedulingApplyResumptionLeaveRecordService schedulingApplyResumptionLeaveRecordService;
    @DubboReference
    private SchedulingApplyLeaveRecordService schedulingApplyLeaveRecordService;
    @DubboReference
    private SchedulingApplyTripRecordService schedulingApplyTripRecordService;
    @DubboReference
    private SchedulingApplyOutRecordService schedulingApplyOutRecordService;
    @DubboReference
    private SchedulingWorkOvertimeConfigService schedulingWorkOvertimeConfigService;
    @DubboReference
    private SchedulingAttendanceDailyApplyService schedulingAttendanceDailyApplyService;
    @DubboReference
    private MongoOriginalCheckRecordService mongoOriginalCheckRecordService;
    @DubboReference
    private SchedulingAttendanceMonthService schedulingAttendanceMonthService;

    @GetMapping("possessedGroups")
    @Operation(summary = "查看管理的考勤组")
    public Response<List<SchedulingAttendanceGroupDto>> possessedGroups(){
        SessionHolder.checkEmp();
        DeptPersonDto deptPersonDto = Objects.requireNonNull(SessionHolder.getLoginEmpSession()).getDeptPersonDto();

        List<SchedulingAttendanceGroupDto> groupList = schedulingAttendanceGroupHeadBindingService.selectGroupByPersonId(deptPersonDto.getId());
        return Response.<List<SchedulingAttendanceGroupDto>>ok().wrap(groupList);
    }
}
